<?php

require_once(WSB_XTENSION_PATH . 'simpleshop/models/DbTable/Article/Rowset.php');
require_once(WSB_XTENSION_PATH . 'simpleshop/models/DbTable/Article/Row.php');

class Simpleshop_Model_DbTable_Article_Table extends WSB_Db_Table
{

    protected $_name 			= 'xt_simpleshop_article';
    protected $_primary 		= 'id';
    protected $_rowsetClass 	= 'Simpleshop_Model_DbTable_Article_Rowset';
    protected $_rowClass 		= 'Simpleshop_Model_DbTable_Article_Row';
    protected $_dependentTables = array();
    protected $_referenceMap    = array(
        'Xtsimpleshop' => array(
            'columns'		=> 'category_id',
            'refTableClass'	=> 'Simpleshop_Model_DbTable_Category_Table',
            'refColumns'	=> 'id'
        )
    );

	protected $_listcols = array('id', 'sorting', 'article_number', 'title');


	/**
	 * @param integer $id
	 * @return Simpleshop_Model_DbTable_Article_Row
	 */
	public function getArticle($id)
	{
		$select = $this->select();
		$select->where('id=?', intval($id));
		$select->where('deleted=?', 0);
		$select->where('hidden=?', 0);
		return $this->fetchRow($select);
	}
}